<style>
    /*.limitDl .nav_title{ border-bottom: 1px solid #f5f5f5; margin: 5px;}*/
    /*.limitDl .nav{border:1px solid #ddd;height:620px;margin-left:92px;overflow:auto;margin-top: -18px; padding: 5px;}*/
    .limitDl .line{ white-space: nowrap; line-height: 30px; border-bottom: 1px solid #f5f5f5; padding: 5px 0; font-size: 0.7rem}
    .limitDl .line1{ line-height: 50px; font-size: 1.0rem;font-weight: 1rem}
    .limitDl .nav_child{ margin-left: 20px;}
    .limitDl{ margin-bottom: 5px;}
    .limitDl dd{ padding-left: 15px;}
</style>
<script>
</script>


<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <h3><?php echo $lang['nc_limit_manage'];?></h3>
            <?php echo $output['top_link'];?>
        </div>
    </div>
    <div class="fixed-empty"></div>
    <form id="add_form" method="post" name="adminForm">
        <input type="hidden" name="form_submit" value="ok" />
        <table class="table tb-type2">
            <tbody>
            <tr class="noborder">
                <td colspan="2" class="required"><label class="validation" for="admin_name"><?php echo $lang['gadmin_name'];?>:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" id="group_name" value="<?php echo $output['ginfo']['group_name'];?>" maxlength="40" name="group_name" class="txt"></td>
                <td class="vatop tips"></td>
            </tr>
            <?php if($output['admin_info']['id']==1): ?>
                <tr class="noborder">
                    <td colspan="2" class="required"><label class="validation" for="admin_name">是否属于超级管理权限组:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <select name="is_super_group">
                            <option value="0" <?php echo $output['ginfo']['is_super_group']==0?'selected':''; ?>>否</option>
                            <option value="1" <?php echo $output['ginfo']['is_super_group']==1?'selected':''; ?>>是</option>
                        </select>
                    </td>
                    <td class="vatop tips" style="color:red;font-size: 20px;">*ps:属于敏感的权限组请选择'是',设置完成之后,该权限组的成员只能由超级管理员添加！其他权限组管理员无权添加！</td>
                </tr>
            <?php endif;  ?>
            <tr>
                <td colspan="2"><table class="table tb-type2 nomargin">
                        <thead>
                        <tr class="space">
                            <!--                            <th> <input id="limitAll" id="limitAll" value="1" type="checkbox">&nbsp;&nbsp;--><?php //echo $lang['admin_set_limt'];?>
                            <!--                            </th>-->
                        </tr>
                        </thead>
                        <tbody>

                        <?php foreach((array)$output['limit'] as $key_a => $val_a) { ?>
                            <dl class="limitDl">
                                <dt class="line1"><?php echo $val_a['name'];?></dt>
                                <?php
                                foreach($val_a['child'] as $key_b => $val_b){
                                    ?>
                                    <dd>
                                        <label class="line"><input class="pcate" id="limit<?php echo $key_a.$key_b;?>" type="checkbox" onclick="selectLimit('limit<?php echo $key_a.$key_b;?>')"><b><?php echo $val_b['name'];?></b>&nbsp;&nbsp;</label>
                                        <br>
                                        <div class="nav_child">
                                            <?php
                                            foreach($val_b['child'] as $val_c){
                                                ?>
                                                <?php if(isset($val_c['params'])){?>
                                                    <label class="line"><input nctype="limit"  class="limit<?php echo $key_a.$key_b;?>" <?php if($val_c['check']){?> rel="check"<?php }?>type="checkbox"  name="permission[]" value="<?php echo $val_c['op'].'.'.$val_c['act'].'.'.$val_c['params'];?>"
                                                            <?php if(in_array($val_c['op'].'.'.$val_c['act'].'.'.$val_c['params'],$output['ginfo']['limits'])){ echo 'checked';}  ?>
                                                        ><?php echo $val_c['name'];?>&nbsp;</label>
                                                <?php }else{?>
                                                    <label class="line">
                                                        <!--                                                        --><?php //if(in_array($val_c['action'].'.'.$val_c['mod'],$output['ginfo']['limits'])){ echo 'checked';}  ?>
                                                        <input nctype="limit"  class="limit<?php echo $key_a.$key_b;?>" <?php if($val_c['check']){?> rel="check"<?php }?>type="checkbox" name="permission[]"
                                                            <?php if(in_array($val_c['op'].'.'.$val_c['act'],$output['ginfo']['limits']))
                                                            {
                                                                echo 'checked';
                                                            }else {
                                                                if(isset($output['thisginfo']) && is_array($output['thisginfo'])){
                                                                if(in_array($val_c['op'].'.'.$val_c['act'],$output['thisginfo']['limits'])) {
                                                                    echo '';
                                                                }else{
                                                                    echo $output['admin_info']['id']==1?'':"disabled";
                                                                }
                                                                }else{
                                                                    echo $output['admin_info']['id']==1?'':"disabled";
                                                                }
                                                            }  ?>
                                                               value="<?php echo $val_c['op'].'.'.$val_c['act'];?>"><?php echo $val_c['name'];?>&nbsp;</label>
                                                <?php }?>
                                                <?php
                                            }
                                            ?>
                                        </div>
                                    </dd>
                                    <?php
                                }
                                ?>
                            </dl>
                        <?php } ?>


                        </tbody>
                    </table></td>
            </tr>
            </tbody>
            <tfoot>
            <tr class="tfoot">
                <td><a href="JavaScript:void(0);" class="btn" onclick="document.adminForm.submit()"><span><?php echo $lang['nc_submit'];?></span></a></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>



<script>
    function selectLimit(name){
        if($('#'+name).attr('checked')) {
            $('.'+name).attr('checked',true);
        }else {
            $('.'+name).attr('checked',false);
        }
    }

    $(function(){
        $("input[class=pcate]").each(function(index){
            var cname = $(this)[0].id;
            var cnodes = $("input[class="+cname+"]");
            var checkNum = 0;
            cnodes.each(function(){
                if ($(this)[0].checked){
                    checkNum++;
                }
                if (checkNum == cnodes.length){
                    $("#"+cname)[0].checked = true;
                }
            })
        });
    })
</script>


